package com.neutech.demo.day03;

import java.util.Scanner;

public class Demo01 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("请输入一个数来得出他最终的码");
        String str = input.nextLine();
//        String str = "692116851128";
        String finalStr = add(str);
    }
    public static String add(String str) {
        int oddSum = 0;
        int evenSum = 0;

        for (int i = 0; i < str.length(); i++) {
            if (i % 2 != 0) {
                //偶数
                int odd = str.charAt(i) - '0';
                oddSum += odd;
//                System.out.println("奇数"+odd);
            } else if (i % 2 == 0) {
                //奇数
                int even = str.charAt(i) - '0';
//                System.out.println("偶数" +even);
                evenSum += even;
            }
        }
        System.out.println("偶数的和为" + oddSum + "奇数的和" + evenSum);
        int sum = 0;
        //奇数与偶数的三倍相加
        sum = evenSum + oddSum * 3;
        //对结果取余
        int remainder = sum % 10;
        //用10减去这个数
        int num1 = 10 - remainder;
        //对得到的数（num1）再对10取余
        int last = num1 % 10;
        String lastNum = last + "";
        str = str.concat(lastNum);
        System.out.println(str);
        return str;
    }
}






















